﻿<!DOCTYPE html>
<html class="no-js" lang="en">
  <head>
    <meta charset="utf-8" />
    <title>会员名册系统</title>
    <meta name="viewport" content="width=device-width, initial-scale=1" />

    <!-- site favicon -->
    <link rel="icon" type="image/png" href="assets/images/favicon.png" />
    <!-- Place favicon.ico in the root directory -->

    <!-- All stylesheet and icons css  -->
    <link rel="stylesheet" href="assets/css/bootstrap.min.css" />
    <link rel="stylesheet" href="assets/css/animate.css" />
    <link rel="stylesheet" href="assets/css/all.min.css" />
    <link rel="stylesheet" href="assets/css/swiper.min.css" />
    <link rel="stylesheet" href="assets/css/lightcase.css" />
    <link rel="stylesheet" href="assets/css/style.css" />
    <style>
      .form-group {
        position: relative;
      }
      .form-button {
        margin-top: 40px;
      }
      .form-button button {
        width: 100%;
        height: 50px;
        background: #eaf2fc;
        color: #213366;
        font-weight: 600;
        font-size: 1.125rem;
        border: 1px solid rgba(59, 54, 140, 0.1);
      }
      .QRcodeImg {
        position: absolute;
        cursor: pointer;
        height: 50px;
        right: 0;
        top: 38px;
      }
    </style>
  </head>

  <body>
    <!-- ================> login section start here <================== -->
    <section class="log-reg">
      <div class="container">
        <div class="row">
          <div class="image image-log"></div>
          <div class="col-lg-7">
            <div class="log-reg-inner">
              <div class="section-header inloginp">
                <h2 class="title">账号登录</h2>
              </div>
              <div class="main-content inloginp">
                <div class="form-group">
                  <label>账号</label>
                  <input
                    type="email"
                    class="my-form-control form-name"
                    placeholder="请输入账号"
                  />
                </div>
                <div class="form-group">
                  <label>密码</label>
                  <input
                    type="text"
                    class="my-form-control form-password"
                    placeholder="请输入密码"
                  />
                </div>
                <div class="form-group">
                  <label>验证码</label>
                  <input
                    type="text"
                    class="my-form-control form-verifyCode"
                    placeholder="请输入验证码"
                  />
                  <img class="QRcodeImg" src="" />
                </div>
                <div class="form-button">
                  <button id="Login">登录</button>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>
    <!-- All Needed JS -->
    <script src="assets/js/vendor/jquery-3.6.0.min.js"></script>
    <script src="assets/js/vendor/modernizr-3.11.2.min.js"></script>
    <script src="assets/js/isotope.pkgd.min.js"></script>
    <script src="assets/js/swiper.min.js"></script>
    <!-- <script src="assets/js/all.min.js"></script> -->
    <script src="assets/js/wow.js"></script>
    <script src="assets/js/counterup.js"></script>
    <script src="assets/js/jquery.countdown.min.js"></script>
    <script src="assets/js/lightcase.js"></script>
    <script src="assets/js/waypoints.min.js"></script>
    <script src="assets/js/vendor/bootstrap.bundle.min.js"></script>
    <script src="assets/js/plugins.js"></script>
    <script src="assets/js/main.js"></script>
    <script src="assets/js/crypto-js.js"></script>
    <script src="assets/js/cookie.js"></script>
    <script src="assets/js/request.js"></script>
    <script>
      $(function () {
        function getCodeImg(random) {
          let verifuCodeSrc = `${baseUrl}/frontier/user/getVerifyCode?time=${new Date().getTime()}`;
          $(".QRcodeImg").attr("src", verifuCodeSrc);
        }

        function login(data) {
          data = JSON.parse(JSON.stringify(data));
          data.password = CryptoJS.MD5(data.password).toString();
          return request("/frontier/user/login", { type: "post", data });
        }
        getCodeImg();
        $(".QRcodeImg").on("click", function () {
          getCodeImg();
        });

        $("#Login").on("click", function () {
          const names = $(".form-name").val();
          const password = $(".form-password").val();
          const verifyCode = $(".form-verifyCode").val();
          if (!names) {
            alert("请输入账号");
            return;
          }
          if (!password) {
            alert("请输入密码");
            return;
          }
          if (!verifyCode) {
            alert("请输入验证码");
            return;
          }
          login({ name: names, password, verifyCode, role: "PAD" }).then(
            (e) => {
              if (e.code === 200) {
                window.location.href = "members.html";
              } else {
                getCodeImg();
                alert(e.msg);
              }
            }
          );
        });
      });
    </script>
  </body>
</html>
